package cn.zt.ztzx.controller;

import cn.zt.ztzx.domain.ShopType;
import cn.zt.ztzx.model.vo.common.Result;
import cn.zt.ztzx.service.ShopTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("admin/shop")
public class ShopTypeConrtroller {
    @Autowired
    private ShopTypeService shopTypeService;


    //商品分类列表展示   分页实现 支持按类别编号、类别名称和父类编号三个条件查询  模糊查询
    @GetMapping("shopList")
    public Result shopList(@RequestParam(defaultValue = "1")Integer pageNum,
                           @RequestParam(defaultValue = "5")Integer pageSize,
                           ShopType shopType){
        return shopTypeService.shopList(pageNum,pageSize,shopType);
    }

    //根据级别查shoptype
    @GetMapping("findByLevel")
    public Result findByLevel(String level){
        return shopTypeService.findByLevel(level);
    }

    //新增
    @PostMapping("addshopType")
    public Result addshopType(ShopType shopType){
        return shopTypeService.addshopType(shopType);
    }

    //删除
    @PostMapping("deleteshopType")
    public Result deleteshopType(Integer id){
        return shopTypeService.deleteshopType(id);
    }

    //修改
    @PostMapping("updateshopType")
    public Result updateshopType(ShopType shopType){
        return shopTypeService.updateshopType(shopType);
    }
}
